package java1;
import java.sql.SQLOutput;
import java.util.Random;

public class RandomArray {




    public static void main(String [] args){
        Random rand = new Random() ; // 创建一个用于产生随机数的对象

        int [] array = new int[7];
        for (int i = 0;i <= 6;i++ ){
            array[i] = rand.nextInt(32)+1;//将随机数放入数组内
            //遍历是否有重复
            for(int j = 0;j < i;j++){
                if(array[i] == array[j]){
                    System.out.println("第" + (i+1) + "个数出现重复数！");
                    i--;
                    break;
                }
            }
        }

        //遍历输出数组
        for (int i : array) {
            System.out.print(i + "  ");
        }

    }
}
